package org.zjblague.blog.model;

import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

import com.google.appengine.api.datastore.Key;

/**
 *  <p><p>
 * 
 * @author 		<a href="mailto:zjblague@gmail.com">Jing Zhang</a>
 * @date 		2011-7-28
 * @version 	test
 *	
 */
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Article {
	
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Unique
	@Persistent
	private String title;
	
	@Persistent
	private String content;
	
	@Persistent
	private Date createTime;
	
	@Persistent
	private Integer hitCount;
	
	@Persistent
	private List<Key> tags;
	
	@Persistent(mappedBy="article")
	private List<Comment> comments;
	
	public Article() {
		super();
	}

	public Article(String title, String content, Date createTime, List<Key> tags) {
		super();
		this.title = title;
		this.content = content;
		this.createTime = new Date();
		this.tags = tags;
	}
	
	
	/**
	 * @return the comments
	 */
	public List<Comment> getComments() {
		return comments;
	}

	/**
	 * @param comments the comments to set
	 */
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	/**
	 * @return the key
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * @param key the key to set
	 */
	public void setKey(Key key) {
		this.key = key;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content the content to set
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @param createTime the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	/**
	 * @return the hitCount
	 */
	public Integer getHitCount() {
		return hitCount;
	}

	/**
	 * @param hitCount the hitCount to set
	 */
	public void setHitCount(Integer hitCount) {
		this.hitCount = hitCount;
	}

	/**
	 * @return the tags
	 */
	public List<Key> getTags() {
		return tags;
	}

	/**
	 * @param tags the tags to set
	 */
	public void setTags(List<Key> tags) {
		this.tags = tags;
	}
	
	

}



